﻿@using System.Web.UI.WebControls
@using UnionistsManagement_DaLat.Areas.Admin.Models
@model IEnumerable<Role>

@{
    ViewBag.Title = "Quản lý phân quyền";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutAdmin.cshtml";
}

<div>
    <ul class="breadcrumb">
        <li>
            <a href="/Admin/Account">Tài khoản</a>
        </li>
        <li>
            <a href="#">Quản lý phân quyền</a>
        </li>
    </ul>
</div>

<div class="row">
    <div class="box col-md-12">
        <div class="box-inner" >
            <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-user"></i> Phân quyền sử dụng</h2>
            </div>
            <div class="box-content">
                @{
                    var messenger = ViewBag.Messenger;

                    <p>@messenger abc </p>
                }

                <div class="alert alert-warning alert-dismissible" role="alert">
                    <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <strong>Warning!</strong> @ViewBag.Messenger
                </div>


                <div class="role-change">

                    @Html.DropDownList("roles", Model.Select(r => new SelectListItem()
                    {
                        Value = r.ID.ToString(),
                        Text = r.RoleName
                    }), "Chọn chức vụ", new { @class = "form-control", id = "roleChange" })

                </div>


                @using (Html.BeginForm())
                {
                    @Html.AntiForgeryToken()
                    <input type="hidden" id="hiden" name="roleId" />
                    <div id="function-box"></div>
                    <div id="btn-save" style="width: 98%; margin: 10px auto;">
                        <input type="submit" value="Lưu" class="btn btn-success" />
                    </div>

                }


            </div>
            </div>
    </div>
    <!--/span-->
</div><!--/row-->




<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
<script>
    $(document).ready(function () {
      


        $("#roleChange").change(function(event) {
            var roleId = $(this).val();
            $("#function-box").html("");
            if (roleId != "" && roleId != null) {
                $("#hiden").val(roleId);
                $.get("/Admin/Account/GetListFunctionByRole", { roleID: roleId }, function(data) {
                    $("#function-box").html(data);
                    $("#btn-save").show();
                });
            }

        });
    });


   

</script>